package org.base.common.query;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;


@Data
public class Query<T> {

    public static final String DESC = "DESC";

    /**
     * 对象ID
     */
    @ApiModelProperty(value = "主键")
    private Long id;

    /**
     * 创建者
     */
    @ApiModelProperty(value = "创建者")
    private String creator;

    /**
     * 最后修改者
     */
    @ApiModelProperty(value = "修改者")
    private String modifier;

    /**
     * 开始创建时间
     */
    @ApiModelProperty(value = "创建开始时间")
    private LocalDate beginCreateDate;

    /**
     * 结束创建时间
     */
    @ApiModelProperty(value = "创建结束时间")
    private LocalDate endCreateDate;

    /**
     * 开始编辑时间
     */
    @ApiModelProperty(value = "修改开始时间")
    private LocalDateTime beginModifiedDate;

    /**
     * 结束编辑时间
     */
    @ApiModelProperty(value = "修改结束时间")
    private LocalDateTime endModifiedDate;

    /**
     * 排序字段
     */
    private String orderByColumn;

    /**
     * 排序字段表达式
     */
    private SFunction<T, ?> orderByColumnFunc;

    /**
     * 排序类型
     */
    private String orderByType;

    @ApiModelProperty(example = "1", value = "当前页")
    private Integer page = 1;

    @ApiModelProperty(example = "10", value = "页大小")
    private Integer pageSize = 10;

    public boolean isOrderByDesc() {
        return orderByType != null && orderByType.toUpperCase().equals(DESC);
    }
}
